<!DOCTYPE html>
<html>
<head>
<!-- <meta charset="UTF-8" />
<meta http-equiv="pragma" content="no-cache"></meta>
<meta http-equiv="cache-control" content="no-cache"></meta>
<meta http-equiv="expires" content="0"></meta>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link th:href="${quickJs}+'scripts/layui/css/layui.css'" rel="stylesheet" />
<script th:src="${quickJs}+'scripts/jquery/jquery-1.11.2.min.js'"></script>
<script th:src="${quickJs}+'scripts/layui/layui.js'"></script> -->
<div th:include="base-libs :: base-libs" />
</head>

<title>签约转介</title>

<style>
.layui-form-select {
	width: 80%;
}

.layui-anim-upbit {
	height: 110px;
	overflow: auto;
}
.layui-form-label{
	font-size:14px;
	font-weight: bold;
}
</style>
<script th:inline="javascript">
	/**读取request中的初始化数据*/
var result = [[${DATA}]];
</script>

<script type="text/javascript">
	var yTDID = result.YTDID;
	var qyxxids = result.QYXXIDS;
	var fwbids = result.FWBIDS;
	$(function(){
		$("#JLS").html("您已经选择了<span style='font-size:14px;font-weight: bold;color:red;padding:0 7px;'>" + result.RS + "</span>记录");

			var $ZJTD = $("#ZJTDID");
			var tdxxArr = result.tdxxArr;
			for(var i=0;i<tdxxArr.length;i++){
				var item = tdxxArr[i];
				if(item.TDID==yTDID){
					var yTDMC = item.TDMC
					$("#QYTD").val(item.TDMC);
					continue; //排除当前团队
				} 
				var option = $("<option>").html(item.TDMC).attr("value",item.TDID);
				$ZJTD.append(option);
			}

		layui.use('form', function(){
			  var form = layui.form();
			  //监听提交
			  form.on('submit(formDemo)', function(data){
			      /**  data.field无法取到值  */
//				  data.field.YQYTD = yTDID;
//				  data.field.QYXXIDS = qyxxids;
//				  data.field.FWBIDS = fwbids;
//				  data.field.USERID = result.USERID;

				  var params = {
                      YQYTD: yTDID,
                      QYXXIDS: qyxxids,
                      FWBIDS: fwbids,
                      USERID:result.USERID,
                      ZJTDID: $("#ZJTDID").val(),
                      XQYYS: $("#XQYYS").val(),
                      ZJYY:$("#ZJYY").val()
				  }
				  $.QuickRemote.AjaxJson(contextRoot + "jtqy/saveZjxx",function(result){
						if (result["state"]) {
						   $.QuickAlert.alertNormal(result.info.success,{callback: function(){
							    StoreCache.setCache("JTQY_OPT_SUCCESS", "true");
								parent.layer.closeAll();
							}});
						} else {
							$.QuickAlert.alertFail({
								content : info["faultInfo"]
							});
						}
					},params);

			  });

			/* 转介团队与签约医生下拉框联动 */
            form.on('select(listenXQYYS)', function(data){
                var TDID = $("#ZJTDID").val();
                $.QuickRemote.AjaxJson(contextRoot + "tdgl/queryTdcylbAll.service", function(result){
                    var $XQYYS = $("#XQYYS");
                    $XQYYS.empty();
                    $.each(result, function(){
                        var option = $("<option>").attr("value",this.USERID).text(this.XM).data("SJHM",this.SJHM);
                        $XQYYS.append(option);
                    })
					form.render('select'); //刷新所有下拉框的渲染
                    //默认选中"签约医生"中的第一个选项
					$("#XQYYS").next().find("dd:first").trigger("click");
					/*转介原因下拉框位置调整*/
					$("#ZJYY").next().find("dl").css("top","-112px");
                }, {TDID:TDID});
            });
            //默认选中"转介团队"中的第一个选项
			$("#ZJTDID").next().find("dd:first").trigger("click");
		});

	});
</script>

<body class="easyui-layout" fit="true" border="false">
	<div region="center" fit="true" border="false" style="overflow: hidden;">
		<div class="layui-form" style="margin-top: 10px;height:100%;overflow: hidden;">

			<div class="layui-form-item" style="text-align: center;margin-bottom:10px;">
				<h1 id="JLS" style="font-size:12px;"></h1>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">签约团队:</label>
				<div class="layui-input-block">
					<input type="text" readonly="true" id="QYTD" autocomplete="off"
						class="layui-input" style="width:80% ;border:none">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">转介团队:</label>
				<div class="layui-input-block">
					<select name="ZJTDID" lay-verify="required" id="ZJTDID" lay-filter="listenXQYYS">
						<option value=""></option>
					</select>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">签约医生:</label>
				<div class="layui-input-block">
					<select name="XQYYS" lay-verify="required" id="XQYYS" >
						<option value=""></option>
					</select>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">转介原因:</label>
				<div class="layui-input-block">
					<select name="ZJYY" id="ZJYY" lay-verify="required">
						<option value="0">原团队解散</option>
						<option value="1">原机构解散</option>
						<option value="2">居住地址变更</option>
					</select>
				</div>
			</div>
		</div>
	</div>
	<div region="south" style="height:45px;text-align:center;line-height: 42px;border:0;border-top:1px solid #ddd;overflow: hidden">
			<div class="layui-btn" lay-submit lay-filter="formDemo">提交</div>
	</div>
</body>
</html>
